<?php
/*
 * @Date: 2021-05-08 11:11:57
 * @Author: yukun
 * @LastEditors: yukun
 * @LastEditTime: 2021-05-08 12:14:01
 * @FilePath: /design-patterns-study/观察者模式/AdObserver.php
 * @Description: 广告模块观察者
 */

class AdObserver implements SplObserver
{
    public function update(SplSubject $subject)
    {
        switch ($subject->hobby) {
            case HobbyConstants::SPORT:
                echo "播放运动广告" . PHP_EOL;
                break;
            case HobbyConstants::FOOD:
                echo "播放食品广告" . PHP_EOL;
                break;
            case HobbyConstants::STUDY:
                echo "播放学习广告" . PHP_EOL;
                break;
            default:
                echo "暂不支持" . PHP_EOL;
                break;
        }
    }
}
